<template>
  <div>
    <div class="d1">
      <p>父组件展示子组件内容：{{age}}</p>
      <button @click="cxgx">调用子组件方法</button>
    </div>
    <div class="d1">
      <Index ref="indexRef"></Index>
    </div>
  </div>
</template>

<script setup>
import { ref, nextTick, watch } from 'vue';
import Index from '../../components/sanDianEr/组件通信ref/index.vue'

let age = ref(0)
let indexRef = ref('indexRef') //暂时没用研究明白子组件跟新 父组件不跟新的问题

//用ref获取子组件 内容需要用 nextTick
nextTick(() => {
  age.value = indexRef.value.age
})




</script>
<style scoped lang ='less'>
</style>